package com.wanhai.base.dao;

import com.wanhai.bean.OracleModuleBean;
import org.springframework.util.Assert;
import org.zkoss.zk.ui.UiException;

public class JndiNameHolder {
	private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
	private static final ThreadLocal<OracleModuleBean> oracleModulBeanHolder = new ThreadLocal<OracleModuleBean>();

	public static void setJndiName(String jndiName) {
                            System.out.println("JndiName :"+JndiNameHolder.getJndiName());

            Assert.notNull(jndiName, "jndiName cannot be null");
            contextHolder.set(jndiName);
	}
        
	public static String getJndiName() {
            return (String) contextHolder.get();
	}

	public static void clearJndiName() {
            contextHolder.remove();
	}
        
        public static void setOracleModuleBean(OracleModuleBean oracleModuleBean) {
            Assert.notNull(oracleModuleBean, "OracleModuleBean cannot be null");
            oracleModulBeanHolder.set(oracleModuleBean);
	}
        
        public static OracleModuleBean getOracleModuleBean() {
            return (OracleModuleBean) oracleModulBeanHolder.get();
	}
        
        public static void clearOracleModuleBean() {
            oracleModulBeanHolder.remove();
	}
}
